package com.pcbly.web.components.utils.template;

import com.pcbly.web.bean.news.NewsBean;
import com.pcbly.web.components.utils.template.action.ModelCommonAction;
import com.pcbly.web.components.utils.template.dao.ModelCommonDao;
import com.pcbly.web.components.utils.template.dwr.ModelDwrGenerator; 
import com.pcbly.web.components.utils.template.pagemess.ModelPageAndMessage;
import com.pcbly.web.components.utils.template.service.ModelCommonService;

@SuppressWarnings("unchecked")
public class Module {

	ModelDwrGenerator dwr;

	ModelCommonAction action;

	ModelCommonDao dao;

	ModelCommonService service;

	ModelPageAndMessage pageAndMessage;
	
	
	Class clz;
	
	String tableName;
	

	public Class getClz() {
		return clz;
	}

	public void setClz(Class clz) {
		this.clz = clz;
	}

	public ModelCommonAction getAction() {
		return action;
	}

	public void setAction(ModelCommonAction action) {
		this.action = action;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public ModelDwrGenerator getDwr() {
		return dwr;
	}

	public void setDwr(ModelDwrGenerator dwr) {
		this.dwr = dwr;
	} 

	public ModelCommonDao getDao() {
		return dao;
	}

	public void setDao(ModelCommonDao dao) {
		this.dao = dao;
	}

	public ModelCommonService getService() {
		return service;
	}

	public void setService(ModelCommonService service) {
		this.service = service;
	}

	public ModelPageAndMessage getPageAndMessage() {
		return pageAndMessage;
	}

	public void setPageAndMessage(ModelPageAndMessage pageAndMessage) {
		this.pageAndMessage = pageAndMessage;
	}

	public void execute() {
		dwr.execute(clz);
		action.execute(clz);
		action.setTableName(tableName);
		dao.execute(clz);
		dao.setTableName(tableName);
		service.execute(clz);
		pageAndMessage.execute(clz);
	}

	public static void main(String[] args) {
		ModelDwrGenerator dwr=new ModelDwrGenerator();

		ModelCommonAction action=new ModelCommonAction();

		ModelCommonDao dao=new ModelCommonDao();

		ModelCommonService service=new ModelCommonService();

		ModelPageAndMessage pageAndMessage=new ModelPageAndMessage();
		Module module=new Module();
		module.setDwr(dwr);
		module.setAction(action);
		module.setDao(dao);
		module.setService(service);
		module.setPageAndMessage(pageAndMessage);
		module.setClz(NewsBean.class);
		module.setTableName("sys_news");
		module.execute();
	}
}
